//
//  CustomView.m
//  UI12_homework_网易
//
//  Created by aaaaaa on 16/6/22.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CustomView.h"
#import "JokesModel.h"

@interface CustomView ()

@property (nonatomic, retain) UIImageView *upImageView;
@property (nonatomic, retain) UIImageView *downImageView;
@property (nonatomic, retain) UIImageView *commentsImageView;
@property (nonatomic, retain) UIImageView *shareImageView;
@property (nonatomic, retain) UILabel *upLable;
@property (nonatomic, retain) UILabel *downLable;
@property (nonatomic, retain) UILabel *commentsLable;
@property (nonatomic, retain) UILabel *bottomLable;

@end

@implementation CustomView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)dealloc
{
    [_upImageView release];
    [_downImageView release];
    [_commentsImageView release];
    [_shareImageView release];
    [_shareImageView release];
    [_upLable release];
    [_downLable release];
    [_commentsLable release];
    [super dealloc];
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.upImageView = [[UIImageView alloc] init];
        [self addSubview:_upImageView];
        [_upImageView release];
        
        self.upLable= [[UILabel alloc] init];
        [self addSubview:_upLable];
        [_upLable release];
        
        self.downImageView= [[UIImageView alloc] init];
        [self addSubview:_downImageView];
        [_downImageView release];
        
        self.downLable= [[UILabel alloc] init];
        [self addSubview:_downLable];
        [_downLable release];
        
        self.commentsImageView = [[UIImageView alloc] init];
        [self addSubview:_commentsImageView];
        [_commentsImageView release];
        
        self.commentsLable = [[UILabel alloc] init];
        [self addSubview:_commentsLable];
        [_commentsLable release];
        
        self.shareImageView = [[UIImageView alloc] init];
        [self addSubview:_shareImageView];
        [_shareImageView release];
        
        self.bottomLable = [[UILabel alloc] init];
        [self addSubview:_bottomLable];
        [_bottomLable release];
        
        
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews{
    
    
    self.upImageView.frame = CGRectMake(10, 10, 32, 32);
    self.upImageView.image = [UIImage imageNamed:@"赞.png"];
    
    self.upLable.frame = CGRectMake(10 + 32, 10, 80, 32);
//    self.upLable.backgroundColor = [UIColor redColor];
    
    self.downImageView.frame = CGRectMake(10 + 32 + 80, 10, 32, 32);
    self.downImageView.image = [UIImage imageNamed:@"赞2.png"];
    
    self.downLable.frame = CGRectMake(10 + 32 + 80 + 32, 10, 80, 32);
//    self.downLable.backgroundColor = [UIColor orangeColor];
    
    self.commentsImageView.frame = CGRectMake(260, 10, 32, 32);
    self.commentsImageView.image = [UIImage imageNamed:@"评论.png"];
    
    self.commentsLable.frame =  CGRectMake(260 + 32, 10, 80, 32);
//    self.commentsLable.backgroundColor = [UIColor grayColor];
    
    self.shareImageView.frame = CGRectMake(260 + 32 + 80, 10, 32, 32);
    self.shareImageView.image = [UIImage imageNamed:@"分享.png"];
    
    self.bottomLable.frame = CGRectMake(0, 42, self.bounds.size.width, self.bounds.size.height - 42);
    self.bottomLable.backgroundColor = [UIColor lightGrayColor];

}

- (void)setJokesModel:(JokesModel *)jokesModel{
    if (_jokesModel != jokesModel) {
        [_jokesModel release];
        _jokesModel = [jokesModel retain];
    }
    

    self.downLable.text = [NSString stringWithFormat:@"%ld", jokesModel.downTimes];
    self.upLable.text = [NSString stringWithFormat:@"%ld", jokesModel.upTimes];
    self.commentsLable.text = [NSString stringWithFormat:@"%ld", jokesModel.replyCount];
}












@end
